<html>
<head>
	<meta charset="utf-8"/>
	<title>全文搜索</title>
	<script src="jquery-1.12.3.min.js" type="text/javascript"></script>
</head>

<style>
	.high-light{color:red};
</style>

<body>
		<input type="text" name="keywords" value="TL-" id="searchResult">
		<select name="type" id="searchSelect">
			<option value="article" selected>test</option>
		</select>
		<button id="searchSubmit">提交</button>
	<div id="test">
		<p>success</p>
	</div>

<script>
$(function(){
	$("#searchSubmit").click(function(){
		$.ajax({
			url: '/Lucene531/servlet/SearchServlet',
            type: 'get',
            dataType: 'json',
            data: { "keywords": $("#searchResult").val(), "type" : $("#searchSelect").val()},
            beforeSend:function(){
            	$('#test').html("");
            },
			success:function(data){
				$('#test').append('<p>'+$("#searchSelect").val()+'</p>');
				$('#test').append('<p>'+'testCount:'+data.testCount+'</p>');
				if(typeof(data.result[0].name)!="undefined"){
					for(var i = 0; i < data.result.length; i++){
						$('#test').append('<p>'+'id:'+data.result[i].id+'</p>');
						$('#test').append('<p>'+'name:'+data.result[i].name+'</p>');
						$('#test').append('<p>'+'model:'+data.result[i].model+'</p>');
						$('#test').append('<p>'+'detail:'+data.result[i].detail+'</p>');
						$('#test').append('<p>'+'classid:'+data.result[i].classid+'</p>');
						$('#test').append('<p>'+'hits:'+data.result[i].hits+'</p>');
						$('#test').append('<p>'+'updatetime:'+data.result[i].updatetime+'</p>');
						$('#test').append('<p>'+'other:'+data.result[i].other+'</p>');
						$('#test').append('<p>'+'visible:'+data.result[i].visible+'</p>');
						$('#test').append('<p>'+'classname:'+data.result[i].classname+'</p>');
						$('#test').append('<p>'+'displayorder:'+data.result[i].displayorder+'</p>');
					}
				}else{
					$('#test').append('<p>'+'return empty object'+'</p>');
				}
			},
			error:function(e){
			}
		});
	});
}); 
</script>
	
</body>
</html>